import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);
//https://www.cnblogs.com/zhengrunlin/p/8981017.html 动态路由
export default new Router({
    linkActiveClass: 'active',
    mode: "history",
    routes: [
        {
            path: "/",
            name: "webLayout",
            redirect: "/home",
            component: () => import("@/components/layout/webLayout.vue"),
            children: [
                {
                    path: "/base",
                    name: "base",
                    component: () => import("@/components/layout/webBase.vue"),
                    meta: {
                        auth: true,
                        role: "web-common"
                    },
                    children: [
                        {
                            path: "/home",
                            name: "麦猫首页",
                            component: () => import("@/views/home.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                        },
                        {
                            path: "/search",
                            name: "搜索页",
                            component: () => import("@/views/search/SearchApp.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                        },
                        {
                            path: "/kill-maimao",
                            name: "麦猫秒杀页",
                            component: () => import("@/views/kill/killPage.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                        },
                        {
                            path: "/goodDetail",
                            name: "商品详情页",
                            component: () => import("@/views/search/goodsDetail.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                        },
                        {
                            path: "/addToCart",
                            name: "添加购物车成功页",
                            component: () => import("@/views/cart/addToCart.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                        },
                        {
                            path: "/cart_index",
                            name: "购物车",
                            component: () => import("@/views/cart/cartIndex.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                        },


                    ]
                },
                {
                    path: "/comment-pub",
                    name: "回复评论",
                    meta: {
                        auth: true,
                        role: "web-common"
                    },
                    component: () => import("@/views/comment/publisbCommenet.vue")
                },
                {
                    path: "/confirm_order",
                    name: "订单确认",
                    meta: {
                        auth: true,
                        role: "web-common"
                    },
                    component: () => import("@/views/order/confirmOrder.vue")
                },
                {
                    path: "/order_pay",
                    name: "订单支付",
                    meta: {
                        auth: true,
                        role: "web-common"
                    },
                    component: () => import("@/views/order/orderPay.vue")
                },

                {
                    path: "/user-apply-shop",
                    name: "普通用户申请店铺",
                    component: () => import("@/views/cell-center/apply/userApply.vue"),
                    meta: {
                        auth: true,
                        role: "web-common"
                    },
                },
                {
                    path: "/shop_apply_result",
                    name: "店铺申请结果",
                    component: () => import("@/views/cell-center/apply/shopApplyResult.vue"),
                    meta: {
                        auth: true
                    }
                },
                {
                    path: "/member-register",
                    name: "会员注册",
                    component: () => import("@/views/login/register/memberRegister.vue"),

                },
                {
                    path: "/company-register",
                    name: "企业注册",
                    component: () => import("@/views/login/register/companyRegister.vue"),

                },

            ]
        },
        {
            path: "/cellLayout",
            name: "cellLayout",
            redirect: "/cell-center",
            component: () => import("@/components/layout/cellLayout.vue"),
            children: [
                {
                    path: "/cell-center",
                    name: "卖家中心",
                    component: () => import("@/views/cell-center/cellCenter.vue"),
                    meta: {
                        auth: true,
                        role: "web-shop"
                    },
                    children: [
                        {
                            path: "/cell-center/cate-choose",
                            name: "选择分类",
                            component: () => import("@/views/cell-center/goods/publish/chooseCate.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/coupon",
                            name: "优惠券管理",
                            component: () => import("@/views/cell-center/shop/couponMS.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/comment",
                            name: "订单管理",
                            component: () => import("@/views/cell-center/comment/commentCenter.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/goods_center",
                            name: "宝贝中心",
                            component: () => import("@/views/cell-center/goods/GoodsCenter.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/goods_center_ware",
                            name: "仓库中心",
                            component: () => import("@/views/cell-center/goods/WareHouseGoods.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/order_index",
                            name: "卖家订单中心",
                            component: () => import("@/views/cell-center/order/cellOrderCenter.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/activity",
                            name: "活动中心",
                            component: () => import("@/views/cell-center/marketing/activity.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/schedule",
                            name: "排期",
                            component: () => import("@/views/cell-center/marketing/scheduleIndex.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/killApply",
                            name: "秒杀报名页",
                            component: () => import("@/views/cell-center/marketing/applyKillGoods.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },
                        {
                            path: "/cell-center/myApply",
                            name: "我的报名",
                            component: () => import("@/views/cell-center/marketing/myApply.vue"),
                            meta: {
                                auth: true,
                                role: "web-shop"
                            },
                        },

                    ]
                },
                {
                    path: "/user-center",
                    name: "用户中心_l",
                    component: () => import("@/views/user_center/userCenter.vue"),
                    meta: {
                        auth: true,
                        role: "web-common"
                    },
                    redirect: "/user-center/base_nav",
                    children: [
                        {
                            path: "/user-center/base_nav",
                            name: "用户中心",
                            component: () => import("@/views/user_center/layout/BaseLeftNav.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                            children: [
                                {
                                    path: "/user-center/order_index",
                                    name: "订单中心",
                                    component: () => import("@/views/user_center/order/orderIndex.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/foot_index",
                                    name: "我的足迹",
                                    component: () => import("@/views/user_center/foot/FootIndex.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/follow_index",
                                    name: "我的关注",
                                    component: () => import("@/views/user_center/follow/FollowIndex.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/integral_center",
                                    name: "我的积分",
                                    component: () => import("@/views/user_center/integral/MyIntegral.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },

                            ]
                        },
                        {
                            path: "/user-center/info_nav",
                            name: "个人信息",
                            component: () => import("@/views/user_center/layout/InfoLeftNav.vue"),
                            meta: {
                                auth: true,
                                role: "web-common"
                            },
                            // redirect: "/user-center/base_info",
                            children: [
                                {
                                    path: "/user-center/base_info",
                                    name: "基本信息",
                                    component: () => import("@/views/user_center/account/BaseInfo.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/securityCenter",
                                    name: "账户安全",
                                    component: () => import("@/views/user_center/account/securityCenter.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/address_ms",
                                    name: "收货地址管理",
                                    component: () => import("@/views/user_center/account/addressMS.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/verify",
                                    name: "认证方式选择页",
                                    component: () => import("@/views/user_center/account/verifyPage.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                                {
                                    path: "/user-center/bindEmail",
                                    name: "邮箱绑定",
                                    component: () => import("@/views/user_center/account/EmailBind.vue"),
                                    meta: {
                                        auth: true,
                                        role: "web-common"
                                    },
                                },
                            ]
                        },


                    ]
                },
                {
                    path: "/publish-goods",
                    name: "商品发布页",
                    component: () => import("@/views/cell-center/goods/publish/publishForm.vue"),
                    meta: {
                        auth: true,
                        role: "web-shop"
                    },
                },
                {
                    path: "/apply-brand",
                    name: "品牌申请",
                    component: () => import("@/views/cell-center/goods/publish/brandApply.vue"),
                    meta: {
                        auth: true,
                        role: "web-shop"
                    },
                },


            ]
        },
        {
            path: "/login",
            name: "登录",
            component: () => import("@/views/login/index.vue")
        },

        {
            path: "/500",
            name: "error",
            component: () => import("@/components/500.vue")
        }
    ]
});
//push
const VueRouterPush = Router.prototype.push;
Router.prototype.push = function push(to) {
    return VueRouterPush.call(this, to).catch(err => err);
};

//replace
const VueRouterReplace = Router.prototype.replace;
Router.prototype.replace = function replace(to) {
    return VueRouterReplace.call(this, to).catch(err => err);
};
